import Mock from 'mockjs2'
import {builder, getQueryParameters} from "@/mock/util";

const totalCount = 100

const datasourceList = (options) => {
	console.log('data source mock:datasourceList')
	console.log(options)
	const parameters = getQueryParameters(options)

	const page = parseInt(parameters.page)
	const pageSize = parseInt(parameters.pageSize)
	const pages = Math.ceil(totalCount / pageSize)
	const next = (page >= pages ? (totalCount % pageSize) : pageSize) + 1
	const data = [
		{"id":7,"name":"人保微盟","type":0,"analysisUrl":"http://localhost:9999","analysisProject":"e0633c498d474c3e9224a6c808cfe1ca","jdbcUrl":null,"jdbcUsername":null,"jdbcPassword":null,"remark":null,"createdAt":"2021-09-15 15:24:15","updatedAt":"2021-09-15 15:24:18"},
		{"id":6,"name":"大数据","type":1,"analysisUrl":null,"analysisProject":"","jdbcUrl":"jdbc:impala://10.139.49.195:21050/default;UseSasl=0;AuthMech=3;UID=impala;PWD=","jdbcUsername":"root","jdbcPassword":null,"remark":"大数据","createdAt":"2021-08-31 14:00:09","updatedAt":"2021-08-31 14:00:13"},
		{"id":4,"name":"路径","type":0,"analysisUrl":"http://localhost:9999","analysisProject":"2d3f59f847f44745b9636a8f4fdd4582","jdbcUrl":null,"jdbcUsername":null,"jdbcPassword":null,"remark":"路径","createdAt":"2021-06-25 16:06:18","updatedAt":"2021-06-25 16:06:20"},
		{"id":3,"name":"mysql1","type":1,"analysisUrl":"","analysisProject":"","jdbcUrl":"jdbc:mysql://localhost:3306/mop_smart_report?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai","jdbcUsername":"root","jdbcPassword":"root","remark":"事件","createdAt":"2021-06-25 16:05:13","updatedAt":"2021-06-25 16:05:16"},
		{"id":2,"name":"mysql","type":1,"analysisUrl":null,"analysisProject":null,"jdbcUrl":"jdbc:mysql://localhost:3306/mop_auth?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai","jdbcUsername":"root","jdbcPassword":"root","remark":"mysql","createdAt":"2021-06-25 16:02:56","updatedAt":"2021-06-25 16:02:59"},
		{"id":1,"name":"oracle","type":1,"analysisUrl":null,"analysisProject":null,"jdbcUrl":"jdbc:oracle:thin:@localhost:1521:xe","jdbcUsername":"hr","jdbcPassword":"hr","remark":"oracle","createdAt":"2021-06-25 15:59:19","updatedAt":"2021-06-25 15:59:16"}]
	const result = builder({

		total: 7,
		size: 10,
		pages: 1,
		current: 1,
		data: data,
	})
	console.log(result)
	return result
}



Mock.mock(/^.*?\/datasource$/ , 'get', datasourceList)
